I have created a dxl GUI, and in that GUI, the user can choose in a multilist, one or two options that are update in a attribute inside the module.
void updateVariables() {
string currentQA = obj."Applicability" ""
string currentQE = obj."Validation Ensure" ""
for iQE in 0:2 by 1 do {
if (currentQE == answerType2.strings[iQE]) { break }
iQE++
}
set(selectChoiceQA, -1)
attrAppliType = find(current Module, "Applicability")
for(attrAppliIndex=0; attrAppliIndex<attrAppliType.size; attrAppliIndex=attrAppliIndex+1) {
if(isMember(obj."Applicability", attrAppliType.strings[attrAppliIndex])) {
set(selectChoiceQA, attrAppliIndex)
}
}
set(tagField, identifier(obj))
set(selectChoiceQE,iQE)
if(null obj."Object Text" "") set(richTextReq, "<Title>") // Avoid headings.
else set(richTextReq, obj."Object Text" "")
refresh current Module
}
void saveObjects(){
string aux = ""
int i
bool wasModified = false
if(canModify(obj)){
aux = get(selectChoiceQE)
if(obj."Validation Ensure" "" != aux) {
obj."Validation Ensure" = aux
wasModified = true
}
aux = get(selectChoiceQA)
if(obj."Applicability" "" != aux) {
obj."Applicability" += aux
wasModified = true
}
// Save checker
if(wasModified){ // Saves Checker just if something has changed.
User u = find() // returns current user login.
string uName = u.name
if(obj."Object Heading" "" == "") obj."Checker" = uName// just save if is requirement.
}
}
else infoBox "Cannot modify current object."
}
Bruwbruw - Mon Mar 12 13:25:34 EDT 2012 |
Re: Problem with multi-valored attribute In updateVariables(), you are incrementing the loop counter inside the loop
In saveObjects() at the bottom, I think you can just do this without issueing a "find":
In saveObjects() you seem to be trying to add an enumerated selected value to a multi-enumerated attribute "Applicability" with the "aux" read from the dialog. I think though that "aux" is all the selected values, whereas the "+=" only works for actual single enerated values.
You can do one of these:
-Louie |
Re: Problem with multi-valored attribute
Thanks!!
void updateVariables()
.
.
.
set(selectChoiceQA, -1)
for(attrAppliIndex=0; attrAppliIndex<answerType3.size; attrAppliIndex=attrAppliIndex+1) {
if(isMember(obj."Applicability", answerType3.strings[attrAppliIndex])) {
set(selectChoiceQA, attrAppliIndex)
}
}
and this to the:
void saveObjects()
.
.
.
for (attrAppliIndex=0; attrAppliIndex<noElems(selectChoiceQA); attrAppliIndex++) {
aux = get(selectChoiceQA, attrAppliIndex)
if (selected(selectChoiceQA, attrAppliIndex)) {
obj."Applicability" += aux
wasModified = true
} else {
obj."Applicability" -= aux
wasModified = true
}
}
|